<template>
    <div class="newaddress">
        <navback :left-arrow="true" left-text="返回" :title ="aid?'编辑地址':'新增地址'" fixed></navback>
        <div>
            <van-address-edit
            :area-list="areaList"
            show-postal
            :show-delete = "!!aid"
            show-set-default
            show-search-result
            :area-columns-placeholder="['选择省', '选择市', '选择区/镇']"
            @save = saveAddress
            @change-default = change
/>          
        </div>
    </div>
</template>

<script>
import { areaList } from '@vant/area-data';
import navback from '../components/Navback.vue'
    export default {
        name:"Newaddress",
        components:{
            navback,
        },
        data(){
            return{
                // 省市区数据
                areaList,
                // 地址aid
                aid:''
            }
        },
        created() {
            // 获取aid
            this.aid = this.$route.query.aid;
            console.log(this.aid);
        },
        methods:{
            saveAddress(content){
                // 选择的地址信息
                console.log(content);
         

                    this.$router.push({
                        name:"Address",
                        query: {content}
                    })
                
            },
            change(value){
                console.log(value);
            }
        }
    }
</script>

<style lang="less" scoped>
    .newaddress{
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background-color: #faf4f4;
    }
</style>